//引入二次封装的axios
import request from "@/utils/request";
//引入接口类型
import type {
  responseCode,
  reqLoginData,
  responseLoginDataAll,
  WxLoginResponseData,
  responseOrderData,
  responseOdersInfo,
  responseWeiXinPay,
  responsePayStatus,
  responseUserInfo,
  CertificatesTypeAll,
  CertificatesParam,
  AddOrUpdateUserParams
} from "./type";
//枚举接口
enum API {
  //获取验证码
  GET_CODE = "/sms/send/",
  //用户登录接口
  LOGIN_URL = "/user/login",
  //微信扫码登录的接口
  WEIXINlOGIN_URL = "/user/weixin/getLoginParam/",
  //提交挂号信息,
  SUBMITORDERS_URL = "/order/orderInfo/auth/submitOrder/",
  //获取订单信息
  GETORDERS_URL = "/order/orderInfo/auth/getOrderInfo/",
  //取消订单的接口
  ORDERCANCEL_URL = "/order/orderInfo/auth/cancelOrder/",
  //支付接口
  WEIXINPAY_URL = "/order/weixin/createNative/",
  //查看支付状态接口
  WEIXINPAYSTATUS_URL = "/order/weixin/queryPayStatus/",
  //获取用户信息接口
  USERINFO_URL = "/user/auth/getUserInfo",
  //获取证件类型接口
  GETCARDTYPE_URL = "/cmn/dict/findByDictCode/",
  //用户认证接口
  USERAUTH_URL = "/user/auth/userAuah",
  //用户订单信息接口
  USERORDERS_URL = "/order/orderInfo/auth/",
  //获取订单
  USERORDERSINFO_URL = "/user/patient/auth/findAll",
  //获取用户列表
  USERLIST_URL = "/order/orderInfo/auth/getStatusList",
  //获取中国地区数据
  GETCHINA_URL = "/cmn/dict/findByParentId/",
  //添加就诊人
  ADDUSER_URL = "/user/patient/auth/save",
  //修改就诊人
  UPDATEUSER_URL="/user/patient/auth/update",
  //删除就诊人
  DELETEUSER_URL = "/user/patient/auth/remove/"
}
//获取验证码接口
export const reqGetCode = (phone: string) =>
  request.get<any, responseCode>(API.GET_CODE + phone);
//用户登录接口
export const reqLogin = (data: reqLoginData) =>
  request.post<any, responseLoginDataAll>(API.LOGIN_URL, data);
//微信扫码登录接口
export const reqWxLogin = (wxRedirectUri: string) =>
  request.get<any, WxLoginResponseData>(
    API.WEIXINlOGIN_URL + `?wxRedirectUri=${wxRedirectUri}`
  );
//用户提交订单接口
export const reqSubmitOrders = (
  hoscode: string,
  scheduleId: string,
  patientId: number
) =>
  request.post<any, responseOrderData>(
    API.SUBMITORDERS_URL + `${hoscode}/${scheduleId}/${patientId}`
  );
//获取订单接口
export const reqGetOrders = (id: string) =>
  request.get<any, responseOdersInfo>(API.GETORDERS_URL + id);
//取消订单的接口
export const reqCancelOrder = (orderId: string) =>
  request.get<any, any>(API.ORDERCANCEL_URL + orderId);
//支付接口
export const reqWeixinPay = (orderId: string) =>
  request.get<any, responseWeiXinPay>(API.WEIXINPAY_URL + orderId);
//查看支付状态接口
export const reqWeixinPayStatus = (orderId: string) =>
  request.get<any, responsePayStatus>(API.WEIXINPAYSTATUS_URL + orderId);
//获取用户信息接口
export const reqUserInfo = ()=>request.get<any,responseUserInfo>(API.USERINFO_URL)
//获取证件类型接口
export const reqGetCertType = (dictCode:string)=>request.get<any,CertificatesTypeAll>(API.GETCARDTYPE_URL+dictCode)
//用户认证接口
export const reqUserAuth = (data:CertificatesParam)=>request.post<any,any>(API.USERAUTH_URL,data)
//用户订单接口信息
export const reqUserOrderInfo = (page:number,limit:number,patientId:string,orderStatus:string)=>request.get<any,any>(API.USERORDERS_URL+`${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`)
//获取订单接口
export const reqGetOrderInfo = ()=>request.get<any,any>(API.USERORDERSINFO_URL)
//获取用户列表
export const reqUserList = ()=>request.get<any,any>(API.USERLIST_URL)
//获取中国地区数据
export const reqGetArea = (parentId:string)=>request.get<any,any>(API.GETCHINA_URL+parentId)
//添加或者修改就诊人接口
export const reqAddOrUpdatePatient = (data:AddOrUpdateUserParams)=>{
  if(data.id) {
    //修改
    return request.put<any,any>(API.UPDATEUSER_URL,data)
  }else {
    return request.post<any,any>(API.ADDUSER_URL,data)
  }
}
//删除用户
export const reqRemoveUser = (id:number)=>request.delete<any,any>(API.DELETEUSER_URL+id)